package someTestExcemple.APITest;

import java.util.Random;

public class MathTest {
    //1.了解Math的常用方法
    public static void main(String[] args) {
        System.out.println(Math.abs(-10)); //取绝对值
        System.out.println(Math.ceil(10.1)); //像上取整--返回的还是double
        System.out.println(Math.floor(10.9)); //向下取整
        System.out.println(Math.round(10.5)); //四舍五入 --返回long
        System.out.println(Math.cbrt(27)); //立方根
        System.out.println(Math.sqrt(16)); //平方根
        System.out.println(Math.pow(2, 3)); //取次方
        System.out.println(Math.max(10, 20)); //取最大值
        System.out.println(Math.random()); //[0.0,1.0)的随机数--double
        //另一种随机数生成器
        Random random = new Random();
        System.out.println(random.nextInt(3)); //取[0,3)的随机整数
    }
}
